﻿using System;

namespace Hvac
{
    /// <summary>
    /// This class is passed to TemperatureChangedEventHandlers.
    /// </summary>
    public class TemperatureChangedEventArgs : EventArgs
    {
        double temperature;
        double lastTemperature;

        public double Temperature
        {
            get { return temperature; }
        }

        public double LastTemperature
        {
            get { return lastTemperature; }
        }

        public TemperatureChangedEventArgs(double oldTemperature, double newTemperature)
        {
            lastTemperature = oldTemperature;
            temperature = newTemperature;
        }
    }

    /// <summary>
    /// Defines the interface to retrieve the current temperature from a sensor.
    /// </summary>
    /// <remarks>The first call to Temperature should raise the TemperatureChanged event.</remarks>
    public interface ITemperatureSensor
    {
        /// <summary>
        /// Gets the current temperature.
        /// </summary>
        /// <returns>Returns temperature</returns>
        double Temperature { get; }

        /// <summary>
        /// Occurs when the temperature changes.
        /// </summary>
        event EventHandler<TemperatureChangedEventArgs> TemperatureChanged;
    }
}
